﻿#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>

typedef double Real;

typedef struct {
	int m;
	int n;
	int data[20][20];
}Matrix;
 
typedef struct 
{
	int n;
	int a;
	int b;
	char s1[255];
	char s2[80];
}Context;

Context context;
 
Matrix* read_mat(Matrix* A)
{
	scanf("%d %d", &A->m, &A->n);
	for (int i = 0; i < A->m; ++i)
		for (int j = 0; j < A->n; ++j)
			scanf("%d", &A->data[i][j]);
	return A;
}

void get_line(char* s)
{
	char c;
	while (scanf("%c", &c))
	{
		if (c == '\r')
			;
		else if (c == '\n')
			break;
		else
			*s++ = c;
	}
	*s = 0;
}

void read_data(Context* ctx)
{
	get_line(ctx->s1);
	get_line(ctx->s2);
}

void do_task(Context* ctx)
{
	int len1 = strlen(ctx->s1);
	int len2 = strlen(ctx->s2);
	int n = len1 - len2;
	for(int i=n;i>=0;--i)
		if (strncmp(ctx->s1 + i, ctx->s2, len2) == 0) {
			for (int j = i + len2; j <= len1; ++j)
				ctx->s1[j-len2] = ctx->s1[j];
			len1 -= len2;
		}
	printf("%s\n", ctx->s1);
}

void solve(Context* ctx)
{
	read_data(ctx);
	do_task(ctx);
}

int main()
{
	freopen("D:/Develop/GitRepos/MOOC/浙江大学/数据结构/201906/DataStructure/M2019秋C入门和进阶练习集/7-159.txt", "r", stdin);
	solve(&context);
	return 0;
}
